function login() {
    //获取用户输入的用户和密码，通过Ajax发送给服务器
    let account = $("#account").val();

    let password = $("#password").val();

    let code = $("#code").val();

    $.ajax("/mgr/Admin/Login", {
        type: "POST",
        data: {
            account: account,
            password: password,
            code:code
        },
        success: function(data, textStatus) {

            // var dataList = data.split("\r\n");
            let datas = JSON.parse(data);
            if (datas.statusCode == 200) {
                let user = JSON.stringify(datas.datas.user);

                sessionStorage.setItem("admin", user);

                alert(datas.errMsg);
				
				
				location.href="href?to="datas.location;
               


            } else {
                alert(datas.errMsg)
            }
        }
    })

}

function dashboard(userid,page){
	
	return new Promise(function(resolve, reject) {
		$.ajax("/dashboard", {
			type: "POST",
			data: {
				
			},
			success: function(data, textStatus) {
				let datas = JSON.parse(data);
				if (user.statusCode == 200) {
					resolve(datas);
				} else {
					reject(datas.errMsg);
				}
			}
		})
	})
	
}

function getUserList(page){
	
	return new Promise(function(resolve, reject) {
		$.ajax("/getUserList", {
			type: "POST",
			data: {
				page:page,
			},
			success: function(data, textStatus) {
				let datas = JSON.parse(data);
				if (datas.statusCode == 200) {
					resolve(datas.datas.list);
				} else {
					reject(datas.errMsg);
				}
			}
		})
	})
	
}

